package net.siufung.simple.demo.service;

import com.google.common.collect.Lists;
import net.siufung.core.model.enums.DataScopeEnum;
import net.siufung.mybatis.permit.DataPermitModel;
import net.siufung.mybatis.permit.MybatisDataPermitService;
import net.siufung.security.api.AuthUtil;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author 陈建峰
 * @since 2022/7/26 10:46 下午
 */
@Primary
@Component
public class MybatisDataPermitServiceImpl implements MybatisDataPermitService {

    @Override
    public List<DataPermitModel> getDataPermitModelList() {
        List<DataPermitModel> dataPermitModelList = Lists.newArrayList();
        DataPermitModel dataPermitModel = new DataPermitModel();
        dataPermitModel.setMethod("net.siufung.market.base.user.mapper.IRoleMapper.selectPage");
        dataPermitModel.setDataScopeType(DataScopeEnum.SELF);
        dataPermitModel.setDataScopeValue(AuthUtil.getUserId());
        dataPermitModelList.add(dataPermitModel);
        dataPermitModel = new DataPermitModel();
        dataPermitModel.setMethod("net.siufung.market.base.user.mapper.IRoleMapper.selectPage_mpCount");
        dataPermitModel.setDataScopeType(DataScopeEnum.SELF);
        dataPermitModel.setDataScopeValue(AuthUtil.getUserId());
        dataPermitModelList.add(dataPermitModel);
//        dataPermitModel = new DataPermitModel();
//        dataPermitModel.setMethod("net.siufung.market.base.user.mapper.IUserRoleMapper.selectList");
//        dataPermitModel.setDataScopeType(DataScopeEnum.DEPT_AND_CHILD);
//        dataPermitModel.setDataScopeValue("1");
        dataPermitModel = new DataPermitModel();
        dataPermitModel.setMethod("net.siufung.market.base.user.mapper.IRoleMapper.selectList");
        dataPermitModel.setDataScopeType(DataScopeEnum.CUSTOMIZE);
        dataPermitModel.setDataScopeValue("created_by = '1'");
        dataPermitModelList.add(dataPermitModel);
        return dataPermitModelList;
    }
}
